#include <fcntl.h>


#include "FreadWrite.h"

//#define FILENAME	"/mnt/mtd2/GenieTek/TPdata.txt"
#define FILENAME	"/mnt/mtd3/TPdata.txt"


int fd;

/****************
*** -1 is failure
***  0 is success
*****************/
int File_Open ( void )
{
	    
     fd = open(FILENAME,O_CREAT | O_RDWR |O_APPEND);     
     if (fd == -1)
     {     	
     	return -1;
    	}    	
    return 0;    
}




int File_Write (char *buf,int size)
{
int count;

	if (fd == -1)
		return 0;

	count = write(fd, buf, size);		// wait 3 sec for VTIME = 30

	if (count < 0)
	{
		return 0;
	}
printf ("in File_Write,count is %d\n",count);
	return count;
}

int File_Read (char *buf,int size)
{
	int count;

	if (fd == -1)
		return 0;

	count = read(fd, buf, size);		// wait 3 sec for VTIME = 30

	if (count < 0)
	{
		return 0;
	}

	return count;
}

void File_Close ( void )
{
		close(fd);
}

